package pers.vinsonws.jianghu.clientwin.global;

import io.netty.channel.Channel;
import pers.vinsonws.jianghu.clientwin.model.ChatRoomClient;
import pers.vinsonws.jianghu.clientwin.model.UserClient;
import pers.vinsonws.jianghu.clientwin.ui.*;
import pers.vinsonws.jianghu.codeCompont.MsgEveryPro;

import javax.swing.*;
import java.util.HashMap;

/**
 * @auther vinsonws
 * @date 2018/11/4 20:57
 * 全局变量
 */
public class Info {
    public static int status = 0; //0未登录、1登录成功、2账号或密码错误、3服务器错误
    public static boolean initUserStatus = true;
    public static boolean initStatus = true;
    public static int id;
    public static String uid;
    public static String userName;
    public static String pwd;
    public static Channel channel;
    public static HashMap<Integer, ChatRoomClient> chatRoomClientHashMap = new HashMap<>();
    public static HashMap<Integer, ChatRoomUi> chatRoomOpened = new HashMap<Integer, ChatRoomUi>();
    public static HashMap<Integer, ChatOneUi> userOpened = new HashMap<>();

    //在线用户
    public static HashMap<Integer, UserClient> userClientHashMap = new HashMap<>();

    //管理页面
    public static HashMap<Integer, ApplyListUi> adminOpreate = new HashMap<>();

    //UI
    public static LoginUi loginUi;
    public static RegisterUi registerUi;
    public static IndexUi indexUi;
    public static OnlineUserUi onlineUserUi;
    public static JTabbedPane tabbedPane;

    public static void closeChannel(){
        MsgEveryPro.Message.Builder builder = MsgEveryPro.Message.newBuilder();
        builder.setDateLong(System.currentTimeMillis());
        builder.setType(6);
        channel.writeAndFlush(builder.build());
        channel.close();
    }
}